<template>
  <div>
    <div class="home-header">
      <div class="top">
        <div class="left">
          <van-icon name="volume" color="#fff" size="18" />
          <span style="margin-left: 6px;color: #fff;font-size: 16px;">系统公告</span>
        </div>
        <div class="right" @click="toList">
          查看全部
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="swiper">
        <van-swipe class="my-swipe" :autoplay="3000" :vertical="true" :show-indicators="false">
          <van-swipe-item v-for="(item,index) in list" :key="'words'+index" @click="toDetail(item.id )">{{item.wordName}}</van-swipe-item>
        </van-swipe>

      </div>
    </div>
  </div></template>

<script>
import { getWords } from '@/api/user';
export default {
  data(){
    return{
      list:[]
    }
  },
  async created(){
    await this.getWordsList()
  },
  methods: {
    toDetail(type) {
      this.$router.push('/notice/list/' + type)
    },
    toList() {
      this.$router.push('/notice/list')
    },
    async getWordsList(){
      const res =await getWords()
      if(res.code ==200){
        this.list = [...res.map.words]
      }
    }
  }
}
</script>

  <style lang="scss" scoped>
  .home-header {
    box-sizing: border-box;
    // width: 100%;
    margin: 10px 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    background: #4A73FD;
    padding: 24px;
    border-radius: 20px;
    .top{
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #fff;
    }
    .swiper{
        width: 100%;
        height: 80px;
        background-color: #fff;
        border-radius: 20px;
        margin-top: 20px;
    }
  }
  .van-swipe-item{
    width: 100%;
    height: 80px;
    line-height: 80px;
    box-sizing: border-box;
    padding-left: 24px;
    font-size: 26px;
    color: #9e9e9e;
    overflow: hidden;
  }
  .my-swipe{
    width: 100%;
    height: 80px;
    line-height: 80px;
  }
  .placeholder {
    width: 100%;
    height: 108px;
  }
  </style>
